package com.yxj02;

import java.util.ArrayList;
import java.util.Collections;

public class PokerDemo {
    public static void main(String[] args) {
        //创建一个牌盒，也就是定义一个集合对象，用ArrayList集合实现
        ArrayList<String> array = new ArrayList<String>();
        //装牌
        /*
        * ♦2，♦3....♦A
        * ♥2....♥A
        * ♠2，...♠A
        * ♣2，...♣A
        * 大王，小王
        * */
        //定义花色数组
        String[] colors = {"♦","♥","♠","♣"};
        //定义点数数组
        String[] numbers = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
        for(String color : colors) {
            for(String number : numbers) {
                array.add(color+number);
            }
        }
        array.add("小王");
        array.add("大王");

        //洗牌，用Collections的shuffle方法
        Collections.shuffle(array);
        //发牌,遍历集合，给3个玩家发牌
        ArrayList<String> yxjArray = new ArrayList<String>();
        ArrayList<String> ymmArray = new ArrayList<String>();
        ArrayList<String> yxxArray = new ArrayList<String>();
        //3张底牌
        ArrayList<String> dpArray = new ArrayList<String>();
        for(int i = 0; i < array.size(); i++) {
            String poker = array.get(i);
            if(i >= array.size()-3) {
                dpArray.add(poker);
            }else if(i % 3 == 0) {
                yxjArray.add(poker);
            }else if(i % 3 == 1) {
                ymmArray.add(poker);
            }else if(i % 3 == 2) {
                yxxArray.add(poker);
            }
        }
        //看牌，三个玩家遍历自己的牌
        lookPoker("杨雪娇",yxjArray);
        lookPoker("杨美美",ymmArray);
        lookPoker("杨晓曦",yxxArray);
        lookPoker("底牌",dpArray);
        //System.out.println(array);
    }
    //看牌的方法
    public static void lookPoker(String name, ArrayList<String> array) {
        System.out.println(name+"的牌是：");
        for(String poker : array) {
            System.out.print(poker+" ");
        }
        System.out.println();
    }
}
